<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUsersModelTables extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('uuid')->default('')->index()->comment('UUID');
            $table->string('username')->default('')->index()->comment('用户名');
            $table->string('password')->default('')->comment('密码');
            $table->string('phone')->default('')->index()->comment('手机号');
            $table->string('nickname')->default('')->comment('昵称');
            $table->string('avatar')->default('')->comment('头像');
            $table->char('status', 50)->default(\App\Constant\Enum::STATUS_ENABLED)->index()->comment('状态');
            $table->string('openid')->index()->comment('OPENID');
            $table->timestamp('registered_at')->nullable()->comment('注册时间');
            $table->timestamp('last_login_at')->nullable()->comment('最近登录时间');
            $table->string('last_login_ip')->nullable()->comment('最近登录IP');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
